<template>
  <u-container-layout>
    <zlrt-table :p="ctx">
      <template #before>
        <zlrt-search :p="ctx"></zlrt-search>
        <div class="tool-bar">
          <el-button type="danger" v-hasPermit="['core:menu:del']" icon="Delete" :disabled="!ctx.selected.length"
            @click="ctx.batchDelete()">
            批量删除
          </el-button>
          <span style="float:right">
            <el-button type="success" v-hasPermit="['core:menu:list']" :loading="ctx.exportLoading" icon="Download"
              @click="ctx.export()">
              导出
            </el-button>
            <el-button type="primary" v-hasPermit="['core:menu:save']" icon="Plus" @click="ctx.showEdit()">
              添加
            </el-button>
          </span>
        </div>


      </template>
      <template #sysType="scope">
        {{ ctx.other.getTypeName(scope.row.sysType, sysTypeOptions) }}
      </template>
      <template #menuType="scope">
        {{ ctx.other.getTypeName(scope.row.menuType, menuTypeOptions) }}
      </template>
      <template #disabled="scope">
        {{ ctx.other.getTypeName(scope.row.disabled, disabledOptions) }}
      </template>
      <template #operation="scope">
        <el-button type="primary" v-hasPermit="['core:menu:save']" link size="small" icon="Plus"
          @click="ctx.showEdit(null,scope.row)">
          新增
        </el-button>
        <el-button type="primary" v-hasPermit="['core:menu:save']" size="small" link icon="Edit"
          @click="ctx.showEdit(scope.row)">
          编辑
        </el-button>
        <el-button type="danger" v-hasPermit="['core:menu:del']" size="small" icon="Delete" link
          @click="ctx.del(scope.row.id)">
          删除
        </el-button>
      </template>
      <template #after>
        <el-dialog v-model="ctx.editVisible" :title="ctx.editAction + ctx.title" width="600px" append-to-body
          :close-on-click-modal="false" @close="ctx.closeEdit()">
          <el-form :ref="(e) => ctx.formRef = e" :model="ctx.editData" :rules="ctx.rules" v-loading="ctx.editLoading"
            label-width="120px" class="demo-ruleForm">
            <el-row>
              <el-col :span="12">
                <el-form-item label="所属系统" prop="sysType">
                  <el-select v-model="ctx.editData.sysType" placeholder="请选择所属系统">
                    <el-option v-for="ite in sysTypeOptions" :key="ite.value" :label="ite.label" :value="ite.value" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="菜单类型" prop="menuType">
                  <el-select v-model="ctx.editData.menuType" placeholder="请选择菜单类型">
                    <el-option v-for="ite in menuTypeOptions" :key="ite.value" :label="ite.label" :value="ite.value" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="菜单名称" prop="menuName">
                  <el-input v-model="ctx.editData.menuName" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="菜单图标" prop="icon">
                  <el-input v-model="ctx.editData.icon" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="路由地址" prop="path">
                  <el-input v-model="ctx.editData.path" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <!-- <el-form-item label="组件路径" prop="component">
                    <el-input v-model="ruleForm.component" />
                  </el-form-item> -->
                <el-form-item label="排序" prop="sort">
                  <el-input v-model="ctx.editData.sort" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="权限标识" prop="perms">
                  <el-input v-model="ctx.editData.perms" />
                </el-form-item>
              </el-col>
              <!-- <el-col :span="12">
                <el-form-item label="是否显示" prop="visible">
                  <el-select v-model="ctx.editData.visible" placeholder="请选择是否显示">
                    <el-option label="是" :value="true" />
                    <el-option label="否" :value="false" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row> -->
              <el-col :span="12">
                <el-form-item label="状态" prop="disabled">
                  <el-select v-model="ctx.editData.disabled" placeholder="请选择状态">
                    <el-option v-for="ite in disabledOptions" :key="ite.value" :label="ite.label" :value="ite.value" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="ctx.editVisible = false">取消</el-button>
              <el-button type="primary" @click="ctx.save()">确定</el-button>
            </span>
          </template>
        </el-dialog>
      </template>
    </zlrt-table>

  </u-container-layout>
</template>

<style>
td.first-cell {
  text-align: left !important;

}
</style>
<script lang="ts" src="./menu.ts"></script>
